viz.graphics.processing = function (canvas, p) {
    p.size(300, 300);
    var font = p.loadFont("Helvetica");
    var fontSize = 12;
    p.textFont(font, fontSize);

    function textWidth(text) {
        var singleLinedLength = 0;
        var multiLinedText = text.split("\n");
        for (var i = multiLinedText.length - 1 ; i >= 0 ; i--) {
            if (singleLinedLength < font.width(multiLinedText[i])) {
                singleLinedLength = font.width(multiLinedText[i]);
            }
        }
        return singleLinedLength * fontSize * 1.1;
    }

    function textHeight(text) {
        return text.split("\n").length * fontSize;
    }

    return {
        size : function (width, height) {
            canvas.width(width);
            canvas.height(height);
            p.size(width, height);
        },
        background : function (gray, alpha) {
            p.background(gray, alpha);
        },
        line : function (x1, y1, x2, y2, gray) {
            p.stroke(gray);
            p.line(x1, y1, x2, y2);
        },
        text : function (text, x, y, gray) {
            p.fill(gray);
            p.text(text, x, y, textWidth(text), textHeight(text));
        },
        textWidth : function (text) {
            return textWidth(text);
        },
        textHeight : function (text) {
            return textHeight(text);
        }
    };
};